package liu.thread.thread.pringabc;

/**
 * 两个线程打印A12B34C56........Z5253
 * @author My
 *
 */
public class Print {
	
	private int shuzi=1;
	private char zimu=65;
	private int counter=0;
	
	
	
	
	public synchronized boolean num() throws InterruptedException{
		
		//线程转换条件
		if(counter==2){
			counter=0;
			notify();
			wait();
		}
		counter++;
		System.out.print(shuzi);
		shuzi++;
		
		//结束条件
		if(shuzi==53){
			notify();
			return false;
		}
		return true;	
	}
	
	
	public  synchronized boolean ABC() throws InterruptedException{
		
		//线程转换条件
		if(shuzi==1){
			wait();
			notify();
			return true;
		}
		System.out.print(zimu);
		zimu++;
		
		//线程转换条件
		notify();
		if(zimu==91){
			notify();
			return false;
		}
		wait();
		return true;
	}

}
